package com.wanwu.channel.notify.controller;

import com.wanwu.channel.notify.biz.TradeOrderDeliveryService;
import com.wanwu.channel.notify.model.DeliveryNotifyReq;
import com.wanwu.channel.notify.model.ResponseObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 确认收货
 */
@RestController
@Slf4j
@RequestMapping("/tradeOrder/delivery")
public class TradeOrderDeliveryController {

    @Resource
    private TradeOrderDeliveryService tradeOrderDeliveryService;

    /**
     * 确认收货状态
     */
    @PostMapping("/confirm")
    @ResponseBody
    public ResponseObject updatePayStatus(@RequestBody DeliveryNotifyReq deliveryNotifyReq) throws Exception {

        ResponseObject responseObject = new ResponseObject();
        responseObject.setCode("200");
        responseObject.setMessage("成功");
        try {
            tradeOrderDeliveryService.syncPayStatus(deliveryNotifyReq);
        } catch (Exception e) {
            log.error("确认收货状态失败", e);
            responseObject.setCode("500");
            responseObject.setMessage("失败");
        }
        return responseObject;

    }

}